using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using BO.Admin;
using BO;

namespace Admin.Controls.Category
{
    public partial class EditCategory : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            ltrTextBox.Text = txtNewsPhoto.ClientID;
            ltrWindow.Text = ExplorerWindow1.ClientID;
            if (!IsPostBack)
            {
                BindData();
            }
        }

        private void BindData()
        {
            DataTable dt = Category_Helper.Get(Utils.QueryString.GetCategoryID());
            if (dt != null && dt.Rows.Count > 0)
            {
                string catname = dt.Rows[0]["Category_Name"].ToString();
                string caticon = dt.Rows[0]["Category_Icon"] != DBNull.Value ? dt.Rows[0]["Category_Icon"].ToString() : String.Empty;
                txtNewsPhoto.Text = caticon;
            }
        }

        protected void btSave_Clicked(object sender, EventArgs e)
        {
            if (txtNewsPhoto.Text.Length > 0)
            {
                Category_Helper.UpdateIcon(Utils.QueryString.GetCategoryID(), txtNewsPhoto.Text);
                BindData();
            }
        }
    }
}